/*
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef IE_EXP_EPUB201_LISTENER_H_
#define IE_EXP_EPUB201_LISTENER_H_

//External includes
#include <vector>
#include <string>

// Abiword includes
#include <ie_exp.h>
#include <ie_Table.h>
#include <pd_Document.h>
#include <px_ChangeRecord.h>
#include <px_CR_Strux.h>
#include <px_CR_Span.h>
#include <px_CR_Object.h>


// EPUB filter includes
#include "EPUB_Document.h"

class IE_Exp_EPUB201_Listener: public PL_Listener
{
public:
	IE_Exp_EPUB201_Listener(PD_Document* doc);
	virtual ~IE_Exp_EPUB201_Listener();

	virtual bool populate(PL_StruxFmtHandle sfh, const PX_ChangeRecord * pcr);
	virtual bool populateStrux(PL_StruxDocHandle sdh, const PX_ChangeRecord * pcr,
			PL_StruxFmtHandle * psfh);
	virtual bool change(PL_StruxFmtHandle sfh, const PX_ChangeRecord * pcr);
	virtual bool insertStrux(PL_StruxFmtHandle sfh,
			const PX_ChangeRecord * pcr, PL_StruxDocHandle sdhNew,
			PL_ListenerId lid,
			void (* pfnBindHandles)(PL_StruxDocHandle sdhNew,
			PL_ListenerId lid, PL_StruxFmtHandle sfhNew));
	virtual bool signal(UT_uint32 Signal);

	EPUB_Shared_Document getDocument();
private:
	PD_Document* m_pSourceDocument;
	EPUB_Shared_Document m_pDocument;
	bool m_inLink;
	/**
	 * Field for storing level of the current cell. In such way it`s
	 * easy to processes tables that are nested into another tables
	 */
	int m_nestedCellLevel;
	bool m_firstRow;
	std::vector<EPUB_Shared_Element> m_elementStack;
	ie_Table m_tableHelper;

};

#endif /* IE_EXP_EPUB201_LISTENER_H_ */
